package com.zhongfl.crm.lixiao.bean.resolve;

import com.heptagram.lixiao.bean.response.customer.LXCustomerResponse;
import com.zhongfl.crm.enums.UserMatchStatus;
import com.zhongfl.crm.model.LxChannel;

import java.util.Objects;

/**
 * 对象转换器 将励销渠道对象转换成CRM渠道对象
 *
 * @author wang.yuchuan
 * @date 2018/6/24
 */
public class ChannelModelResolver implements ModelResolver<LxChannel,LXCustomerResponse.DataResult> {

    @Override
    public LxChannel resolve(LXCustomerResponse.DataResult obj) {
        if(Objects.isNull(obj)){
            return null;
        }
        LxChannel lxChannel = new LxChannel();
        lxChannel.setLxId(obj.getId());
        lxChannel.setName(obj.getName());
        lxChannel.setMatchStatus(UserMatchStatus.YES);
        lxChannel.setApproveStatus(obj.getApproveStatus());
        lxChannel.setCategory(obj.getCategory());
        lxChannel.setCategoryMapped(obj.getCategoryMapped());
        lxChannel.setApproveStatusI18n(obj.getApproveStatusI18n());
        lxChannel.setCreatedAt(obj.getCreatedAt());
        lxChannel.setUpdatedAt(obj.getUpdatedAt());
        lxChannel.setCreatorId(obj.getCreator().getId());
        lxChannel.setCreatorName(obj.getCreator().getName());
        lxChannel.setIndustry(obj.getIndustry());
        lxChannel.setIndustryMapped(obj.getIndustryMapped());
        lxChannel.setStatus(obj.getStatus());
        lxChannel.setStatusMapped(obj.getStatusMapped());
        lxChannel.setCompanyName(obj.getCompanyName());
        lxChannel.setUserId(obj.getUser().getId());
        lxChannel.setUserName(obj.getUser().getName());
        lxChannel.setStaffSize(obj.getStaffSize());

        return lxChannel;
    }
}
